package com.itheima.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author kabuda
 * @create 2022-08-24 21:13
 */
@RestController
@RequestMapping("/hello")
public class HelloController {
    @RequestMapping("/add")
    @PreAuthorize("hasRole('ROLE_ADMIN')")//需要ROLE_ADMIN角色才能访问
    public String add(){
        System.out.println("add");
        return "success";
    }
    @RequestMapping("/delete")
    @PreAuthorize("hasAuthority('add')")//需要add权限才能访问
    public String delete(){
        System.out.println("delete");
        return "success";
    }

}
